#include<bits/stdc++.h>
using namespace std;
const int SIZE=100005;
int a[SIZE];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n;cin>>n;
    priority_queue<int,vector<int>,greater<int> > q;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        q.push(a[i]);
    }
    int ans=n,tmp1=q.top(),tmp2=-1,cnt1=0,cnt2=0,rest=0;
    while(q.top()==tmp1){
        cnt1++;q.pop();
    }
    tmp2=q.top();
    while(!q.empty()){
        int x=q.top();q.pop();
        if(x==tmp2){
            cnt2++;
            continue;
        }
        if(cnt2>=cnt1){
            if(cnt2>=cnt1+rest)
                ans-=cnt1+rest;
            else
                ans-=cnt2,rest=(cnt1+rest)-cnt2;
        }else
            ans-=cnt2,rest+=cnt1-cnt2;
        tmp1=tmp2;
        cnt1=cnt2;
        tmp2=x;
        cnt2=1;
    }
    if(cnt2>=cnt1){
        if(cnt2>=cnt1+rest)
            ans-=cnt1+rest;
        else
            ans-=cnt2;
    }else
        ans-=cnt2;
    cout<<ans<<endl;
    return 0;
}
